/**
 * 添加或者修改页面
 */
var LineBannerInfoDlg = {
    data: {
        id: "",
        pic: ""
    }
};

layui.use(['form', 'admin', 'ax','laydate','upload','formSelects'], function () {
    var $ = layui.jquery;
    var $ax = layui.ax;
    var form = layui.form;
    var admin = layui.admin;




    //普通图片上传
    var upload = layui.upload;
    upload.render({
        elem: '#pic'
        ,url: Feng.ctxPath + '/system/uploadFtp' //改成您自己的上传接口
        ,done: function(res){
            $('#picview').html('<img src="'+ res.data +'" alt="" class="layui-upload-img">');
            $('#picval').val(res.data);
            Feng.success("上传成功！");
        }
        ,error: function(){
            Feng.error("上传文件失败！");
        }
    });

    //表单提交事件
    form.on('submit(btnSubmit)', function (data) {
        var ajax = new $ax(Feng.ctxPath + "/lineBanner/addItem", function (data) {
            Feng.success("添加成功！");
            window.location.href = Feng.ctxPath + '/lineBanner'
        }, function (data) {
            Feng.error("添加失败！" + data.responseJSON.message)
        });
        ajax.set(data.field);
        ajax.start();

        return false;
    });

    $('#cancel').click(function(){
        window.location.href = Feng.ctxPath + '/lineBanner'
    });

});